﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
using BCNPCObject.DB;
using DbLinq;
using DbLinq.Oracle;
using CMISLibrary.Entities;
using CMISLibrary;

namespace BCNPCObject
{
    public class cls_NPC_BCKD07_Controller
    {
        #region   Atributes

        private DataSet CMIS_Header = new CMISOutputParameter();
        private DataSet ds = new DataSet();
        private DataTable dt = new DataTable();
        private NPC_BCKD07 info;

        #endregion

        #region   Constructor

        public cls_NPC_BCKD07_Controller()
        {
            info = new NPC_BCKD07();
        }
        public cls_NPC_BCKD07_Controller(NPC_BCKD07 Info)
        {
            this.info = Info;
        }

        #endregion

        #region   Properties

        public NPC_BCKD07 pInfor
        {
            get { return info; }
            set { info = value; }
        }

        #endregion

        #region  DungNT NPC

        public IEnumerable<NPC_BCKD07> Get_BCKD07(string p_madonvi, Int16 p_thang, Int16 p_nam)
        {
            //DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            try
            {
                var q = from p in CMIS2.DB.NPC_BCKD07
                        where p.MA_DVIQLY == p_madonvi
                        && p.THANG == p_thang && p.NAM == p_nam
                        select p;
                   
                return q;
            }
            catch
            {
                CMIS2.ResetDB();
                return null;
            }
        }
        public bool update_BCKD07()
        {
            try
            {
                NPC_BCKD07 obj_NPC_BCKD07 = CMIS2.DB.NPC_BCKD07.Single(c => c.MA_DVIQLY == info.MA_DVIQLY && c.MA_DONVI == pInfor.MA_DONVI && c.THANG == pInfor.THANG && c.NAM == pInfor.NAM);
                //NPC_BCKD07 obj_NPC_BCKD07 = new NPC_BCKD07();
                //obj_NPC_BCKD07.MA_DVIQLY = pInfor.MA_DVIQLY;
                //obj_NPC_BCKD07.MA_DONVI = pInfor.MA_DONVI;
                //obj_NPC_BCKD07.THANG = pInfor.THANG;
                //obj_NPC_BCKD07.NAM = pInfor.NAM;
                obj_NPC_BCKD07.DIEN_NHAN = pInfor.DIEN_NHAN;
                obj_NPC_BCKD07.DIEN_GIAO = pInfor.DIEN_GIAO;
                obj_NPC_BCKD07.DIEN_TP = pInfor.DIEN_TP;
                obj_NPC_BCKD07.TL_KH = pInfor.TL_KH;
                CMIS2.DB.NPC_BCKD07.UpdateOnSubmit(obj_NPC_BCKD07);
                return true;
            }
            catch
            { return false; }
        }
        public bool submitChange(ref string strMaLoi)
        {
            try
            {
                CMIS2.DB.SubmitChanges();
                CMIS2.ResetDB();
                return true;
            }
            catch (Exception ex)
            {
                strMaLoi = ex.ToString();
                return false;
            }
        }
        #endregion
    }


}
